package xyz.zxcwxy999.news.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xyz.zxcwxy999.news.dao.CommentDao;
import xyz.zxcwxy999.news.entity.Comment;

import java.util.Date;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    CommentDao commentDao;

    /**
     * 获取全部评论
     *
     * @param nid
     * @return
     */
    @Override
    public Comment[] getAllComments(int nid) {
        return commentDao.getAllComments(nid);

    }

    /**
     * 删除一条评论
     *
     * @param cid
     * @return
     */
    @Override
    public int deleteOneComment(int cid) {
        return commentDao.deleteOneComment(cid);
    }

    /**
     * 添加一条评论
     *
     * @param comment
     * @return
     */
    @Override
    public int addOneComment(Comment comment) {
        comment.setDate(new Date());
        return commentDao.addOneNews(comment);
    }
}
